package com.ftg.learn.bus.sharecar_userecord.controller;

import com.ftg.learn.bus.role.entity.Role;
import com.ftg.learn.bus.sharecar_userecord.pojo.sharecar_userecord_admin;
import com.ftg.learn.bus.sharecar_userecord.service.Sharecar_Userecord_Admin_Service;
import com.ftg.learn.bus.util.ResultType;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@Api(value = "公车使用登记管理",tags = "公车使用登记管理")
public class Sharecar_Userecord_Admin_Controller {
    @Autowired
    Sharecar_Userecord_Admin_Service auas;

    @GetMapping("/sharecar/query")
    @ApiOperation("查询全部公车使用信息")
    public List<sharecar_userecord_admin> query(){
        return auas.query();
    }

    @PutMapping("/sharecar/queryone/{usecar_id}")
    @ApiOperation(value = "查一条")
    public sharecar_userecord_admin queryOne(@ApiParam("汽车id") @PathVariable String usecar_id){
        return auas.queryOne(usecar_id);
    }

    @PostMapping("/sharecar/insert")
    @ApiOperation(value = "添加")
    public int insert(sharecar_userecord_admin sua){
        return auas.insert(sua);
    }

    @ApiOperation(value = "修改")
    @PostMapping("/sharecaruseupdate")
    public int update(sharecar_userecord_admin sua,String usecar_id){
        return auas.update(sua,usecar_id);
    }

    @GetMapping("/sharecar/querybylimit/{page}&{limit}&{usecar_id}&{principal}")
    @ApiOperation("查询全部+模糊查询+分页")
    public ResultType<sharecar_userecord_admin> query(@ApiParam("页数") @PathVariable int page,@ApiParam("每页条目数") @PathVariable int limit,@ApiParam("id的模糊") @PathVariable String usecar_id,@ApiParam("负责人") @PathVariable String principal){
        return auas.query(page, limit,usecar_id,principal);
    }

    @PutMapping("/sharecar/delete")
    @ApiOperation(value = "删除")
     public int delete( String id){
        return auas.delete(id);
     }
}
